package com.ting.test.algorithms.大厂刷题班;

import com.ting.test.algorithms.二叉树.TreeNode;

/**
 * 验证二插搜索树
 * 特征
 * 左子树的节点一定小于右子树
 */
public class 验证对车二插树 {

    public static void main(String[] args) {
        TreeNode node = new TreeNode(3);
        boolean es = process(node.getRight(), node.getRight());
    }

    private static boolean process(TreeNode left, TreeNode right) {
        if (left == null && right == null) {
            return true;
        }
        if (left != null && right != null) {
            boolean flag = left.getVal() == right.getVal();
            flag = flag && process(left.getRight(), right.getLeft());
            flag = flag && process(left.getLeft(), right.getRight());
            return flag;
        }

        return false;


    }
}
